package com.example.hzz.criminalintent;

import android.content.Context;

import java.util.ArrayList;
import java.util.UUID;

/**
 * Created by huangzezhan on 2018/8/23.
 */

public class CrimeLab {

    private static CrimeLab sCrimeLab = null;
    private Context mContext;
    private ArrayList<Crime> Crimes;

    private CrimeLab(Context context) {
        mContext = context;
        Crimes = new ArrayList<Crime>(100);
        for (int i=0;i<100;i++){
            Crime mCrime = new Crime();
            mCrime.setmTitle("Crime #"+i);
            mCrime.setmSolved(i%2==0);
            Crimes.add(mCrime);
        }
    }

    public static CrimeLab getInstance(Context context) {
        if (sCrimeLab == null) {
            sCrimeLab = new CrimeLab(context.getApplicationContext());
        }
        return sCrimeLab;
    }

    public ArrayList<Crime> getCrimes(){
        return Crimes;
    }

    public Crime getCrime(UUID id){
        for (Crime mCrime:Crimes){
            if (mCrime.getmId().equals(id)){
                return mCrime;
            }
        }
        return null;
    }

}
